package com.yunnuo.com.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yunnuo.com.core.PageReq;
import com.yunnuo.com.core.ResponseResult;
import com.yunnuo.com.domain.entity.MasterTest;
import com.yunnuo.com.service.MasterTestService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yunnuo
 * @since 2022-05-27
 */
@RequestMapping("/master/test")
@RestController
public class MaterTestController {

    private final MasterTestService service;


    public MaterTestController(MasterTestService service) {
        this.service = service;
    }

    @PostMapping("page")
    public ResponseResult<IPage<MasterTest>> page(@RequestBody PageReq pageReq) {
        Page<MasterTest> masterTestPage = new Page<>(pageReq.getPageIndex(), pageReq.getPageSize());
        return ResponseResult.success(service.page(masterTestPage));
    }

    @PostMapping("save")
    public ResponseResult<Boolean> save(@RequestBody MasterTest req) {
        return ResponseResult.success(service.save(req));
    }

}
